package edu.hnnu.sport_event.controller;

import edu.hnnu.sport_event.entity.Admin;
import edu.hnnu.sport_event.entity.Student;
import edu.hnnu.sport_event.service.RegisterService;
import edu.hnnu.sport_event.utils.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class RegisterController {

    @Resource
    RegisterService service;

    @RequestMapping("student/register")
    public Result studentRegister(Student student) {
        if (service.studentRegister(student) == 1) {
            return Result.success("注册成功");
        }
        return Result.error("注册失败，检查输入字段");
    }

    @RequestMapping("admin/register")
    public Result adminRegister(Admin admin) {
        if (service.adminRegister(admin) == 1) {
            return Result.success("注册成功");
        }
        return Result.error("注册失败，检查输入字段");
    }

}
